package com.company.bookstore;

//import com.company.bookstore.test.CustomProducer;
import com.company.bookstore.entities.user_admin_module.Schedule;
import com.company.bookstore.qo.user_admin_module.ScheduleQo;
import com.company.bookstore.schedule.ScheduleController;
import com.company.bookstore.service.user_admin_module.ScheduleService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * BookstoreApplication
 * 吴经纶，赵云霞，江洪锦，姬深威
 * @blame Android Team
 */
@SpringBootApplication
@EnableTransactionManagement  //开启事物支持
@MapperScan("com.company.bookstore.mapper.*")
public class BookstoreApplication {
    //    @Resource
//    CustomProducer customProducer;
    @Resource
    ScheduleService scheduleService;
    public static void main(String[] args) {
        SpringApplication.run(BookstoreApplication.class, args);
    }
    @Bean
    public BCryptPasswordEncoder getBCryptPasswordEncoder(){
        return new BCryptPasswordEncoder();
    }
    @Bean
    public CommandLineRunner version(){
        return args -> {
            List<Schedule> list = scheduleService.list();

            ScheduleController.registerTask(list);
            System.out.println("CURRENT VERSION IS V2");
        };
    }

}
